package com.inventory.service.product;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.inventory.persistence.Product;
import com.inventory.persistence.ProductExample;
import com.inventory.persistence.dao.ManufacturerMapper;
import com.inventory.persistence.dao.ProductMapper;
import com.inventory.persistence.dao.ProductTypeMapper;

public class ProductServiceImpl implements ProductService {
	@Autowired
	private ProductTypeMapper productTypeMapper;
	@Autowired
	private ManufacturerMapper manufacturerMapper;
	@Autowired
	private ProductMapper productMapper;

	@Override
	public List<Product> getProductByProductNamePattern(String pattern) {
		ProductExample productExample = new ProductExample();
		productExample.createCriteria().andProductCodeLike("%" + pattern + "%").andProductNameLike("%" + pattern + "%");
		return productMapper.selectByExample(productExample);
	}

	public void setProductTypeMapper(ProductTypeMapper productTypeMapper) {
		this.productTypeMapper = productTypeMapper;
	}

	public void setManufacturerMapper(ManufacturerMapper manufacturerMapper) {
		this.manufacturerMapper = manufacturerMapper;
	}

	public void setProductMapper(ProductMapper productMapper) {
		this.productMapper = productMapper;
	}

}
